import math
print("""
***************************************
        驻波要发神经！！！！！！！！！
        快乐弱智计算器（）
        作者：独之 陈   日期：2025/3/26
***************************************
""")
def add(x, y):
    return x + y
def subtract(x, y):
    return x - y
def multiply(x, y):
    return x * y
def divide(x, y):
    if y == 0:
        return "被除数不能为零"
    return x / y
def power(x, y):
    return x ** y
def square_root(x):
    if x < 0:
        return "被开方数应大于等于0"
    return math.sqrt(x)
def sin(x):
    return math.sin(math.radians(x))
def cos(x):
    return math.cos(math.radians(x))
def tan(x):
    if math.cos(math.radians(x)) == 0:
        return "tan(x)无意义"
    return math.tan(math.radians(x))
def log(x):
    if x <= 0:
        return "真数应该大于0"
    return math.log10(x)
def complex_add(x, y):
    return x + y
def complex_subtract(x, y):
    return x - y
def complex_multiply(x, y):
    return x * y
def complex_divide(x, y):
    if y == 0:
        return "被除数不能为0"
    return x / y
def display_menu():
    print("科学计算器菜单:")
    print("1. 加法")
    print("2. 减法")
    print("3. 乘法")
    print("4. 除法")
    print("5. 幂运算")
    print("6. 平方根")
    print("7. 正弦")
    print("8. 余弦")
    print("9. 正切")
    print("10. 常用对数")
    print("11. 复数加法")
    print("12. 复数减法")
    print("13. 复数乘法")
    print("14. 复数除法")
    print("0. 退出")

while True:
    display_menu()
    choice = input("请输入你的选择 (0-14): ")
    if choice == '0':
        break
    if choice in ('1', '2', '3', '4', '5'):
        num1 = float(input("请输入第一个数字: "))
        num2 = float(input("请输入第二个数字: "))
        if choice == '1':
            print(num1, "+", num2, "=", add(num1, num2))
        elif choice == '2':
            print(num1, "-", num2, "=", subtract(num1, num2))
        elif choice == '3':
            print(num1, "*", num2, "=", multiply(num1, num2))
        elif choice == '4':
            print(num1, "/", num2, "=", divide(num1, num2))
        elif choice == '5':
            print(num1, "**", num2, "=", power(num1, num2))
    elif choice in ('6', '7', '8', '9', '10'):
        num = float(input("请输入一个数字: "))
        if choice == '6':
            print("√", num, "=", square_root(num))
        elif choice == '7':
            print("sin(", num, ") =", sin(num))
        elif choice == '8':
            print("cos(", num, ") =", cos(num))
        elif choice == '9':
            print("tan(", num, ") =", tan(num))
        elif choice == '10':
            print("log(", num, ") =", log(num))
    elif choice in ('11', '12', '13', '14'):
        real1 = float(input("请输入第一个复数的实部: "))
        imag1 = float(input("请输入第一个复数的虚部: "))
        num1 = complex(real1, imag1)
        real2 = float(input("请输入第二个复数的实部: "))
        imag2 = float(input("请输入第二个复数的虚部: "))
        num2 = complex(real2, imag2)
        if choice == '11':
            print(num1, "+", num2, "=", complex_add(num1, num2))
        elif choice == '12':
            print(num1, "-", num2, "=", complex_subtract(num1, num2))
        elif choice == '13':
            print(num1, "*", num2, "=", complex_multiply(num1, num2))
        elif choice == '14':
            print(num1, "/", num2, "=", complex_divide(num1, num2))
    else:
        print("无效的选择，请重新输入。")
# import math
# def add(x, y):
#     return x + y
# def subtract(x, y):
#     return x - y
# def multiply(x, y):
#     return x * y
# def divide(x, y):
#     if y == 0:
#         return "被除数不能为零"
#     return x / y
# def power(x, y):
#     return x ** y
# def square_root(x):
#     if x < 0:
#         return "被开方数不能小于0"
#     return math.sqrt(x)
# def sin(x):
#     return math.sin(math.radians(x))
# def cos(x):
#     return math.cos(math.radians(x))
# def tan(x):
#     if math.cos(math.radians(x)) == 0:
#         return "Error: tangent of 90 degrees or its multiples"
#     return math.tan(math.radians(x))
# def log(x):
#     if x <= 0:
#         return "真数应大于零"
#     return math.log10(x)
# def display_menu():
#     print("计算器菜单:")
#     print("1 加法")
#     print("2 减法")
#     print("3 乘法")
#     print("4 除法")
#     print("5 幂运算")
#     print("6 平方根")
#     print("7 正弦")
#     print("8 余弦")
#     print("9 正切")
#     print("10 常用对数")
#     print("0 退出")
#
# while True:
#     display_menu()
#     choice = input("请输入你的选择 (0-10): ")
#
#     if choice == '0':
#         break
#
#     if choice in ('1', '2', '3', '4', '5'):
#         num1 = float(input("请输入第一个数字: "))
#         num2 = float(input("请输入第二个数字: "))
#         if choice == '1':
#             print(num1, "+", num2, "=", add(num1, num2))
#         elif choice == '2':
#             print(num1, "-", num2, "=", subtract(num1, num2))
#         elif choice == '3':
#             print(num1, "*", num2, "=", multiply(num1, num2))
#         elif choice == '4':
#             print(num1, "/", num2, "=", divide(num1, num2))
#         elif choice == '5':
#             print(num1, "**", num2, "=", power(num1, num2))
#     elif choice in ('6', '7', '8', '9', '10'):
#         num = float(input("请输入一个数字: "))
#         if choice == '6':
#             print("√", num, "=", square_root(num))
#         elif choice == '7':
#             print("sin(", num, ") =", sin(num))
#         elif choice == '8':
#             print("cos(", num, ") =", cos(num))
#         elif choice == '9':
#             print("tan(", num, ") =", tan(num))
#         elif choice == '10':
#             print("log(", num, ") =", log(num))
#     else:
#         print("无效的选择，请重新输入。")

# def Csum(num1,num2):
#     return num1 + num2
# def Csub(num1,num2):
#     return num1 - num2
# def Cmulti(num1,num2):
#     return num1 * num2
# def Cdiv(num1,num2):
#     return num1 / num2
# flag = True
# while flag:
#     num1 = int(input("请输入一个数"))
#     num2 = int(input("请输入另一个数"))
#     choice1 = input("请输入运算符:+-*/")
#     if choice1 == "+":
#         print(num1,choice1,num2,Csum(num1,num2))
#     elif choice1 == "-":
#         print(num1,choice1,num2,Csub(num1,num2))
#     elif choice1 == "*":
#         print(num1, choice1, num2, Cmulti(num1, num2))
#     elif choice1 == "/":
#         if num2 == 0:
#             print("被除数不能为零！")
#             break
#         else:
#             print(num1,choice1,num2,Csub(num1,num2))
#
#
# print()